package com.wl.index.Mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wl.entity.ChilderComments;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface ChilderCommentsMapper extends BaseMapper<ChilderComments> {
    //通过cid和nid查询子评论
    @Select("select * from childercomments where cid=#{cid} and nid=#{nid}")
    List<ChilderComments> getChilderCommentsByCid(Integer cid,Integer nid);

    //通过用户id查找用户信息
    @Select("select cc.*,u.uname,u.head from childercomments cc left join lvuser u on cc.uid = u.uid where nid = #{nid} and cid=#{cid}")
    List<Map<String,Object>> getCCommentsByUid(Integer cid,Integer nid);

    //添加评论
    @Insert("insert into childercomments (context, creat_at, cid, uid,nid) values (#{context}, #{creatAt}, #{cid}, #{uid}, #{nid})")
    int addChilderComments(ChilderComments childerComments);
}

